//  Author:
//       Daniel Großer <olav.daniel.grosser@googlemail.com>
//  
//  Copyright (c) 2012 Copyright (C) 2012 by Daniel Großer. This Code is under GNU LGPL 3.0
// 
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU Lesser General Public License for more details.
// 
//  You should have received a copy of the GNU Lesser General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Linq;
using Beauty.Contract;

namespace Beauty.Tools
{
    /// <summary>
    /// Legacy implementation of ISourcePart.
    /// This class is meant to be used for the following scenario:
    /// <example>
    /// <code>
    /// [Keyword("Begin")]
    /// public Token BeginToken { get; set; }
    /// </code>
    /// This is useful when a UI should need the information to do code coloring.
    /// </example>
    /// </summary>
    public class Token : ISourcePart
    {
        #region Constructors
        /// <summary>
        /// Create a new instance.
        /// </summary>
        public Token()
        {
        }

        /// <summary>
        /// Create a new instance from a piece of source code.
        /// </summary>
        /// <param name="text">The piece of source code giving this token.</param>
        public Token(string text)
        {
            TokenText = text;
        }
        #endregion

        /// <summary>
        /// Get/Set the line, where the node starts.
        /// </summary>
        public uint LineStart { get; set; }
        /// <summary>
        /// Get/Set the line, where the node ends.
        /// </summary>
        public uint LineEnd { get; set; }
        /// <summary>
        /// Get/Set the column, where the node starts.
        /// </summary>
        public uint ColumnStart { get; set; }
        /// <summary>
        /// Get/Set the column, where the node ends.
        /// </summary>
        public uint ColumnEnd { get; set; }

        public string TokenText { get; protected set; }

        /// <summary>
        /// Get a string representation.
        /// </summary>
        /// <returns><see cref="TokenText"/></returns>
        public override string ToString()
        {
            return TokenText;
        }
    }
}
